//
// Created by bill3000 on 2/16/21.
//

#include <iostream>
#include <fstream>
#include <string>
#include <cstring>

#ifndef INTELLI_MYLOGGER_HPP
#define INTELLI_MYLOGGER_HPP

typedef enum LogLevel {
    INFO,
    WARNING,
    ERROR,
    FATAL
}LogLevel;

typedef struct LogMessage {
    long mtype;
    char text[512];
} LogMessage;

class Logger {
public:
    static void start_logger_thread(const std::string& file_name);
    static void wait_logger_thread();
    static void stop_logger_thread();
    static void dispose();
    static void start(LogLevel level, const std::string& message,
                      const std::string& file, int line, const std::string& function);

private:
    static void start_logger_thread();
    static void* logger_thread(void *data);

    static int m_mq_id;
    static std::ofstream *m_log_file;
    static pthread_t logger_thread_id;
};

#define LOG(level, message) Logger::start(level, message, __FILE__, __LINE__,__FUNCTION__)

#endif //INTELLI_MYLOGGER_HPP
